import lazyLoadView from '@/router/lazy-load';
import { createRouter, createWebHashHistory } from 'vue-router';
import createRouteGuard from './guard';
import { appRoutes, remoteRoutes } from './routes';
import { REDIRECT_MAIN, NOT_FOUND_ROUTE } from './routes/base';

const router = createRouter({
  history: createWebHashHistory(),
  routes: [
    {
      path: '/',
      redirect: 'login',
    },
    {
      path: '/login',
      name: 'login',
      component: lazyLoadView(() => import('@/views/login/index.vue')),
      meta: {
        requiresAuth: false,
      },
    },
    {
      path: '/vls',
      name: 'VLS',
      component: lazyLoadView(() => import('@/views/vls/index.vue')),
      meta: {
        requiresAuth: false,
      },
      redirect: '/vls/overview',
      children: [
        {
          path: '/vls/overview',
          name: 'Overview',
          component: lazyLoadView(() => import('@/views/vls/overview.vue')),
        },
        {
          path: '/vls/elder',
          name: 'Elder',
          component: lazyLoadView(() => import('@/views/vls/elder.vue')),
        },
        {
          path: '/vls/device',
          name: 'Device',
          component: lazyLoadView(() => import('@/views/vls/device.vue')),
        },
        {
          path: '/vls/homecare',
          name: 'Homecare',
          component: lazyLoadView(() => import('@/views/vls/homecare.vue')),
        },
      ],
    },
    // {
    //   path: '/big-screen',
    //   name: 'BigScreen',
    //   component: lazyLoadView(() => import('@/views/big-screen/index.vue')),
    //   meta: {
    //     requiresAuth: false,
    //   },
    // },
    {
      path: '/reset-password',
      name: 'ResetPassword',
      component: lazyLoadView(() => import('@/views/reset-password/index.vue')),
      meta: {
        requiresAuth: false,
      },
    },
    ...appRoutes,
    ...remoteRoutes,
    REDIRECT_MAIN,
    NOT_FOUND_ROUTE,
  ],
  scrollBehavior() {
    return { top: 0 };
  },
});

createRouteGuard(router);

export default router;
